home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_013 / patch.abc < prev    next >
Text File  |  1992-05-06  |  2KB  |  54 lines

  1. 100   ' ----------------------------- Patcher ---------------------------
  2.  110   '
  3.  120   '                         by George Musser Jr.
  4.  130   '                            5 January 1986
  5.  140   '
  6.  150   '  This little routine places a specified patch at the desired place
  7.  160   '  in a file, generating a file with the extension ".Patched".
  8.  170   '
  9.  180   ' Name of file to patch
  10.  190   fil$="ram:CLI"
  11.  200   ' Desired patch
  12.  210   patch$="CON:0/9/530/191/New CLI Window"
  13.  220   ' Location of patch, found by using TYPE OPT H
  14.  230   loc%=&h264
  15.  240   ' Open files
  16.  250   open "i",1,fil$
  17.  260   open "o",2,fil$+".Patched"
  18.  270   ' Loop through file
  19.  280   patched%=0
  20.  290   ptr%=1
  21.  300   while not eof(1)
  22.  310   ' Fill buffer
  23.  320   line input #1,buf$
  24.  330   ' Replace lost linefeed
  25.  340   ' N.B. Watch out if last character in file is line feed
  26.  350   if len(buf$)<255 and not eof(1) then buf$=buf$+chr$(10)
  27.  360   ' If already patched, then finish off file
  28.  370   if patched% goto 570
  29.  380   ' New position in file
  30.  390   ptr%=ptr%+len(buf$)
  31.  400   ' If not yet at patch site, dump buffer and try again
  32.  410   if ptr%<loc% goto 570
  33.  420   ' Output bytes before desired location
  34.  430   print #2,using "&";left$(buf$,len(buf$)-ptr%+loc%+1);
  35.  440   ' Output patch
  36.  450   print #2,using "&";patch$;
  37.  460   ' Make sure buffer is full
  38.  470   buf$=mid$(buf$,len(buf$)-ptr%+loc%+2)
  39.  480   while not eof(1) and len(buf$)<255
  40.  490   get #1,ch$
  41.  500   buf$=buf$+ch$
  42.  510   wend
  43.  520   ' Print remainder of buffer
  44.  530   buf$=mid$(buf$,len(patch$)+1)
  45.  540   ' Done with patching
  46.  550   patched%=-1
  47.  560   ' Put buffer in output file
  48.  570   print #2,using "&";buf$;
  49.  580   wend
  50.  590   ' Bye, bye
  51.  600   close
  52.  610   end
  53.                                                                                  
  54.